﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Renci.iRods.Common;
using System.Collections.ObjectModel;

namespace Renci.iRods.Packets
{
    //#define InxIvalPair_PI "int iiLen; int *inx(iiLen); int *ivalue(iiLen);" 
    [Packet("InxIvalPair_PI")]
    internal class IntegerValuePairPacket : Packet
    {
        [PacketField("iiLen", 0, DataTypes.Int)]
        public int Length { get; private set; }

        [PacketField("inx", 1, DataTypes.Int, true)]
        public DataObjectAttributes[] Key { get; private set; }

        [PacketField("ivalue", 2, DataTypes.Int, true)]
        public int[] Value { get; private set; }

        public IntegerValuePairPacket(IDictionary<DataObjectAttributes, QueryColumnAction> columns)
        {
            if (columns != null)
            {
                this.Length = columns.Count;
                this.Key = (from c in columns select c.Key).ToArray();
                this.Value = (from c in columns select (int)c.Value).ToArray();
            }
            else
            {
                this.Length = 0;
            }
        }
    }
}
